import pandas as pd
import os

name_list=['算法','数据挖掘','图像']
input_file="data4_1_old_data.xlsx"
data1=pd.read_excel(input_file)
print("原始Panda数据：")
print(data1)
data1=data1.values
print('转换为NumPy数据：')
print(data1)
for name1 in name_list:
    print("正在分离包含有\"{}\"的".format(name1)+"数据")
    output_file='./data4_1_classify_name/{}'.format(name1)+".xlsx"
    directory = 'data4_1_classify_name'
    if not os.path.exists(directory):
        os.makedirs(directory)
    name=[]
    class1=[]
    sex=[]
    math=[]
    Chinese=[]
    for item in data1:
     if name1 in item[0]:
        name.append(item[0])
        class1.append(item[1])
        sex.append(item[2])
        math.append(item[3])
        Chinese.append(item[4])
    data2={"name":name,'class1':class1,'sex':sex,"math":math,"Chinese":Chinese}
    data2=pd.DataFrame(data2)
    data2.to_excel(output_file)
    print(data2)

